package com.bayair.doctor.ui.inquiry_record;

import android.view.View;
import android.widget.LinearLayout;
import com.bayair.doctor.R;
import com.bayair.doctor.mvp.BaseMVPFragment;
import com.bayair.doctor.mvp.annotation.InjectPresenter;
import com.blankj.utilcode.util.NetworkUtils;
import com.tencent.qcloud.tim.uikit.modules.conversation.base.ConversationInfo;

import java.util.List;

import butterknife.BindView;

public class InquiryRecordFragment extends BaseMVPFragment implements InquiryRecordContract.View {

    @BindView(R.id.record_layout)
    SessionLayout mLayout;
    @BindView(R.id.ll_inquiryR_net)
    LinearLayout mLlNetView;

    @InjectPresenter
    InquiryRecordPresenter mPresenter;

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_inquiry_record;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initData() {

    }

    @Override
    protected void setListener() {

    }

    @Override
    public void onResume() {
        super.onResume();
        log("onResume");
        mPresenter.getData();

        setNetView();
    }

    @Override
    public void updateListData(List<ConversationInfo> infoList) {
        mLayout.updateDataList(infoList);

        //测试自定义会话
        //SessionHelper.customConversation(mLayout);
    }

    @Override
    public void updateData(ConversationInfo info) {
        mLayout.updateSingleData(info);
    }

    private void setNetView() {
        if (!NetworkUtils.isConnected()) {
            mLlNetView.setVisibility(View.VISIBLE);
        } else {
            mLlNetView.setVisibility(View.GONE);
        }
    }

}
